package com.szzg10.thinking.chapter18;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class BasicFileOutput {

	public static final String FILE_NAME_OUT = "C:/Users/ZhongGe/Desktop/test.txt";
	
	public static void main(String[] args) throws IOException {
		File file = new File(BufferedInputFile.FILE_NAME);
		FileReader fileReader = new FileReader(file);
		BufferedReader bufferedReader = new BufferedReader(fileReader);
		
		File fileOut = new File(FILE_NAME_OUT);
		FileWriter fileWriter = new FileWriter(fileOut);
		BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
		PrintWriter printWriter = new PrintWriter(bufferedWriter);
		
		int lineCount = 1;
		String str;
		while((str = bufferedReader.readLine()) != null) {
			printWriter.println(lineCount + ": " + str);
			lineCount++;
		}
		
		bufferedReader.close();
		printWriter.close();
	}
}
